package ch.ethz.inf.shop.model;

import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;

public class ShoppingCartLine {

	public ShoppingCartLine(int cartLineId, int amount, Product product, BigDecimal linePrice) {
		this.cartLineId = cartLineId;
		this.amount = amount;
		this.product = product;
		this.linePrice = linePrice;
	}

	public ShoppingCartLine(final ResultSet rs) throws SQLException {
		this.product = new Product(rs);
		this.amount = rs.getInt("amount");
		this.cartLineId = rs.getInt("shopping_cart_line_id");
		this.linePrice = rs.getBigDecimal("line_price");
	}

	final private int amount;
	final private Product product;
	final private BigDecimal linePrice;
	final private int cartLineId;

	public int getCartLineId() {
		return cartLineId;
	}

	public int getAmount() {
		return amount;
	}

	public BigDecimal getLinePrice() {
		return linePrice;
	}

	public String getName() {
		return product.getName();
	}

	public int getWeight() {
		return product.getWeight();
	}

	public String getCountryOfOrigin() {
		return product.getCountryOfOrigin();
	}

	public Category getCategory() {
		return product.getCategory();
	}

	public Brand getBrand() {
		return product.getBrand();
	}

	public int getProductId() {
		return product.getProductId();
	}
}
